Two phase lib + model require

This allows database initialization to be customized and resolves #19.