XMAP: Tidy up of code