fixes for syntax and encoding bugs