Fix #508 #427
Merge pull request #608 from weitsai/master

Fix #508 #427