Helper functions on devices, minor fixes.