Consolidated code and documentation

Consolidated code structure, updated and added code documentation to allow generating a proper documentation using JSDuck.
`name = nameOrBase` is missing here, isn't it?