More robust setup, and no longer shits itself when database is empty