add comments
misc formatting
free stored FunPtrs after termination