[PATCH 0/3] leak fixes and buffer allocation optimization