Do you mean that you can perfectly create new pages based on those changed master pages/templates - just not edit the old ones?
Have you tried temporarily setting the theme of the template back to 'basic', this should get rid of all styling issues. (content will look bad, but functionality should be restored)
If that's not the case then perhaps you removed a placeholder or made a typo in the code that inadvertently closes the code premature so the footer gets dropped to the top.
Thirdly if things are still borked, try removing the <head> placeholder and the scriptmanager.
Sorry I don't have any conclusive answers, but hope it helps.