removed bugs that occured if delete_rawdata flag was set True