Cleaning up XF logic