improved comments throughout. They were in weird places so it should be a bit more clear whats going on.