more refactoring - move files, use destructuring rather than mutation for passing values around, start documenting internals
more jsdoc blocks
use reorderImports helper for strict mode AMD/UMD
centralise some shared functions