code cleanup.

Remove unnecessary json object creation and added debug logging messages.