Consolidated code and documentation

Consolidated code structure, updated and added code documentation to allow generating a proper documentation using JSDuck.