Added print_db function and beautified the log. Changed the way popularity is tracked.