Combined patches and 2 new

I've merged together some of the fixes from a few other forks and also added a couple commits to account for problems with instances that don't have any devices and/or don't have a device without any partition numbers.