Replace series of if-checks with a switch to make it more extensible and allow for a "default" - namely, the db is not NULL, but also not recognised, which isn't currently handled and so leads to a confusing error (object 'out' not found)
Merge pull request #379 from Ironholds/master

patch children.default to make more extensible and the error messages more sensible