re-organize file, add rmalloc for memory debug