syntax
fix protocol violations and improve error handling (fixes #1880)