removed unused randstring method, added listener for statechangeerror, cleaned up some jshint issues