documenting and DRY-ing up

* documented return values of functions and methods

* DRY-ed up thread initialization code

* wrote generateJson function
added (but didn't populate) router data JSON file
fixed for loops and corrected numerous typos