Add batch db actions and popularity counter

This addresses issue #1 .