Some fixes and my solution to problem 6