Refactoring: elimination of some getDevice() calls