Fix for issues #548 and #529