bugfix in specialize_dynamic