Fixed issue #353 and other things