Replaced repeating code with a library call
Improved various methods
removed debugging comments
Fixed more code repetition flaws
Merge pull request #36 from Daxda/master

Multiple improvements and logical error fixes