Implemented lazy/dynamic database discovery

Fixes #156