Refactor models. Refactor app to export REST API