Bug fixes to homework 5