Cleanup

With JSLint + some refactoring of if...else into switch...case and whitespace removal