Revision of Brian's threading support library to be a bit more generic and