Fixed issue #227 and #202