Fixed some timing issues with device open and close, and probably made running a sequence
of commands a bit safer.