Fix#1395 and Fix#1396

This contains 2 commits for 2 defects:

1. Fix for: http://eden.sahanafoundation.org/ticket/1395
Which is in turn for GCI task: http://www.google-melange.com/gci/task/view/google/gci2012/8173206
I'm still looking for lazy branch isssue mentioned by Dominic. Do not merge yet.

2. Fix for: http://eden.sahanafoundation.org/ticket/1396
Which is in turn for GCI task: http://www.google-melange.com/gci/task/view/google/gci2012/8152206

Please also close these GCI tasks if you get the chance. 

Thanks