Refactor io.Program to be more declarative.

Fix bug in json module.