First pass at the changes suggested by Jens, bugzilla id 710446