lots of refactoring - moved error code management and general scalate rendering to commons