Refactor models and node_api

The long lines here should also be split.