Fix statistics script to work with 0.6 database schema.