Fix minor bugs and syntax errors