Some work and some refactoring