Minor refactoring and code comments.
JSON API now actually hits the selected host.