patch for issue: 291,289,279,255. YG

Manuel:
Please review and merge this patch.
Yuyi