Log output to file
Remove File logging
Write values to the pipe and the log file instead of junk data
Only loop 2048 times (HARDCODED) and protect database against bogus periods
Temporarily don't write to pipe for logging
Loop phase pointer around when last sample is in last position in the array
Only write to the file/pipe if the data is good and there are no problems
Comment stack operations
Write data to pipe again