Fixes null fields and improves JSON results.

Closes #388.