Added json encoding for ajax debugging