Bug fixes, json writing related, and flush often so that server/client controls when to send results
Merge pull request #1 from voltprime/master

JSON related fixes