Fixed #173
Improvements to fix #173