Added string.strip to the get_rname_base - now shouldn't get trailing newlines.
Added debug message.
Added some missing add_seen_ifs.