Minor bugs and syntax cleanup