Using DB-agnostic implementation for easier testing (OMS-372)
Fixes of issues found during testing + improved generalized implementation of SQL DB user stats logger (OMS-372)