a lot of minor fixes that manifested as weird CS behavior