finished part 1 patch for bug 843004 - cleanups and fixes