Fix requested by Daniel and large refactor