Refactoring almost done

DBManager almost has all the intended functionality.