More robust handling of foreign keys with schema namespaces

Closes issue #89