Reindented to 4 spaces.
Added comments and moved things around