Fixing issue #323 and #322.