Refactoring towards more explicit layering