Attempt to clean up the munging functions a little.