Initial code (taken from qusbmon.googlecode.com)