Changed architecture, added tests