avoid constructing unnecessary objects
Merge pull request #3018 from yanns/ws-mini-fixes

avoid constructing unnecessary objects