Start sharing common code using XWMM.util

Rather than duplicating utility functions for each section move them to
one location and share it between them.