to avoid a circular dependency. This is a modified version of the submitted patch, any errors are likely mine. Submitted by: ale@