kevin rosenbergs code from http://git.b9.com/?p=kmrcl.git;a=summary