Re-rolled patch #77. Attached interdiff for same.
Please review.