A bit of much needed refactoring ...