fix some bug and add new specific function, like delaying memory allocation