error handlers and other improvements