Refactored some code, didn't change too much substantial

(other stuff has been moved to Old for quick reference)