Refactored Db query component and related classes