Fix some minor bugs in code.