restructured REST api to make better use of class inheritance