Extract library code from main activity, make DB a singleton