cleanup the output to console function a bit, refactor some of the database stuff