A few logic and syntax fixes.