Refactoring and splitting, trying to give more flexibility