some refactoring and some breakage