Fixed bugs in code.