refractored all

pre-testing
tested and fixed
resolved conflicts