Cleanup

Things are starting to get a bit out of hand, which too much interleaving and random string constants and repetitive code to be maintainable. 

This PR represents a major cleanup in code documentation and code separation. This also means that unit test coverage will be increased with this PR.

Pull request is currently a work in progress.