Minor refactorings

Refactored to make the code a bit more easy to read.
Merge pull request #3 from Cipherwraith/patch-3

Minor refactorings