Fixes for #510
Merge pull request #1202 from imthinhvu/patch-1

Fixes for #510