Make codepade conversion more general