Fixed issue #642
Tried to fix #659
Fixed issue #654