Some refactors I noticed when reading through the code.
Merge pull request #1 from pasku/master

Some refactors I noticed when reading through the code. [After much deliberation]