Revert "Revert "Many Changes, mostly refactoring""

This reverts commit dc3627582c5b83aa3f7dd9fc9bd649b104915e27.