Refactor models and node_api

This should be split over multiple lines.