adjust proc->target_class according to surrounding proc->target_class; based on a patch from @Fleurer; close #1627