Changed a bit to make it easier to refactor
Merged a solution. Other minor changes