changes for KWS and minor cleanup