You replaced the cable and housing? If you've done that, adjusted the derrailleur properly and it still won't move close enough to the frame and moves too far away, even after adjusting the stops, it could be that this is a bottom bracket or crankset issue. Maybe the bb spindle is too long for the frame. How does the chainline look?