move patches to patches dir
move db code to a Db class, move classes to lib/
move databases to db/
move output functions into a separate class