fixing formatting and some bugs in core.js