Fixes and improvements to homework 3