Lots of little code tweaks

Mainly code style/getting rid of inconsistencies.