Wrote tree allocate and free operations