Cleaned up event handling in node_api's interface.