A lot more refactoring...