Fix small syntax and logic bugs.