Updated code with a few fixes that I missed