Sync up with upstream, with kws improvements