added proper tracing, multiple db support