Remove unneeded stuff, reorganize and reindent