Add more indices and cleanup code a bit to make it easier to add functions
for rethinkdb to call.