Reviewed patch for bug 1083983