patch memory improvements