Move condition outside loop
Don't write files with just a newline
Allow killing all processes at once
Remove some dead API code
Disentangle API/database code; conslidate data logging