started refactoring everything with some lessons learned, still awhile left to go. this commit is not very stable.