input checking
add NULL pointers to FlattenedPowerPotential
better freeing of used memory
remove unused