Cleaned the code

There were a few fixes that I resolved too. There hasn't been much merging activity in the repo. Maybe if you like.