Major rework to be much cleaner