Solution to problem 4
Some cosmetic fixes to problems 1,2 and 3