Initial refactoring (not working commit)