Fixed issue #214, #236 and #243