Ported ws-cleanup