Bugfixes, more efficient code, etc.

Better constructing
More compatible with google closure compiler ADVANCED_OPTIMIZATIONS
Bugfixes