Modified for CDV 3 and up.