Fix IndexError on empty database. Fixes #98