Improving exception safety of the Device classes
Refactoring; no functional changes
Simplifying close() methods of the Database classes