The indentation system on emacs is brilliant for most languages but manually going through and tabbing the lines to get the correct indentation is such a waste of time.
First select everything in the buffer C-x h
Next fix indentation! M-x indent-region
And thats it! Everything should be indented to the correct level.