fixed some discovered issues

Has a hacky patch on the same named object issue. If you have a better one, which seems likely, I'd prefer that.