big application restructure and rework

reworked and restructure
introduced app and lib classes
preparation for more object oriented approach