#642 fixed code in states.js which was reverted by another commit. Updated rest endpoints to use new template structrue code for all CRUD. Updated some rest URLs to be more OO restful. Wired up templates to both load from and save to server.