Intermediate commit, some refactoring