some memory improvements