Fixed bugs and formatted code for submission.
Fixed bugs.