refactored a bit of restful api, still not stable or final by any means