cleanup: use valid_ptr_min/max. get rid of POINTER_MAX