Fix for issue #279 and #267