code cleanup and jshinting