edit for smaller signal
minor corrections and removal of debug code