Do not segfault when no device is present

Fixes #1

Signed-off-by: Andrew 'Necromant' Andrianov <andrew@ncrmnt.org>