Pretty json and error handling