Replicated logic from custom meta functions

Allows initialization and upgrade to occur before function files are included. Fixes issue #533