fixes #3: add an "error" event; change api;