Initial refactoring
more refactoring