Cleanup: bugs, JSHint, whitespace, etc.