markup validation and cleanup