Fixed bugs in the existing code that kept it from running.