Move db status updates to set_status method and ignore redundant operations.
Code tidy.
Merge pull request #625 from arjclark/check-redundant-state-updates

Check redundant state updates