Merge pull request #450 from jonohart/master

Fix for an issue with writing switches to the database.