Major refactor - more to come