Do not connect to the database unless necessary
Add some additional timing to find slowness in code
Merge pull request #8 from mbek/patch-7

Do not connect to the database unless necessary