cleanup of type coercion code