A bunch of suggested changes

I touched a few different parts where I saw potential for improvement, this includes a fix for #198.

My understanding of the code base currently very limited, so I'd appreciate if you could look through these commits and either integrate them as a whole or tell me which you think aren't a good idea.