Fix issue #328 and minor improvements