Update default.py

Reorganize slightly so that there is only one commit to db for the entire loop.
Merge pull request #41 from blizzard2/master

Reduce commits to db (big improvement on Rpi)