Fixed how error handlers are attached