Refactoring (working progress...)