prevent overreleasing to corrupt the reference counter

a warning message and a return code to indicate the failure should be
issued by the release_ref() function. probably something like what malloc/free
does ... offering also a breakpoint
minor cleanings