Minor fixes and follow up on Kacper's refactoring.
Merge pull request #3 from Happyr/Refactoring

Minor fixes and follow up on Kacper's refactoring.