heavy refactor of whole app