Cleanup error handling code, remove assertions