cleanup of mate code