Initial version (blatantly ripped from Restrict Categories)