Fix detection of active module bundles.
Refactor manual SQL to DBAL abstraction layer for multi-database compatibility.