merge in some rlim hacks from elsewhere