extensive header cleanup for standards conformance & correctness