Fixing issue #315 and possibly/partially issue #319.