save some memory by reordering allocation/deallocation order