Code cleanup, refactor and enhanced data layer, rest services