Refactoring towards more RESTful js interface