Fixed bug where length scaling would be applied several times
This required some refactoring