fixed a bug and some jslint errors.