Code now seems to work. Took out printfs.