Some more changes (unit tests) and last restructuring before minmax