Moved some functionality out to mam.util