Fixed fugly hack.
Added json output.