hotfix 20140814

This fix:
* Adds more exception handling for database commits, rolling back the transaction where necessary
* Adds logic to select the first available challenge if the default challenge is not available (this should fix #290)
* Removes some excessive debug output.