Patch for Issue #707 and #778 (0.9-work)

Application of #1096 for 0.9-work branch