Some code refactoring; code style fix; jsDoc fix;