ran the code through jshint, fixed a few errors, added use strict mode.