Fixes for unused declaration markers

Fix #747.

I try to guard against exceptions in automatic features by adding 'protectOrDefault' and 'protect'. Let me know if I miss any feature that should have been protected. Possibly this is a fix for #790.