clean up hdr code