Fixing PR #334 and #333