more code cleanup and jslint