Modularizing the app. More fixes. Not tested yet, dont have much time