refactor some js and clean up gruntfile