Skimmed through and fixed some bugs