Fixes to the x-ray, general code-cleaning