Huge syntax fixing. Changed from tab indentation to 2 spaces. Used JSHint to fix many discrepancies in syntax.