re-indented code to 2 spaces per tab, removed jslint errors wherever possible