Refactor to remove static db dependency

add config and db manager classes. remove relevant methods from reader
and writer class.