The bug fix from Sean is here

Please add the bug fix from Sean, coz its awesome.