(unfinished) add same unused code from kfoltman. Still needs lots of cleanup and signal processing