Added comments
minor code clean up
haste error will trigger javascript exception (instead of just a log message)