cleaned up code for readability and corrected error with marker names
repair xrefs bug