Some minor refactoring and added a (currently trivial) normalization step