Externalised common functions of the mv mashines.

This avoids code duplications and helps to define new mv mashines