Add pretty JSON. Improve factory