updated TODO with resampling code
added checks for NULL pointers
set freed pointers to NULL