Cleanup whitespace and conditions

Done with the help of JSHint ( http://www.jshint.com ).