Heavy changes, added REST support