Fixed db. Moving code to common. Fixes