Refactor of XP stuff to use it in all the places.