Really fix issue #405 and #536.
Merge pull request #543 from sledgehammer999/master

Really fix issue #405 and #536.