Moved functions around & fixed errors with JSLint