Reorder the code to simplify the memory management. Signed-off-by: George Bosilca <bosilca@icl.utk.edu>