removed manual json string output and various bug fixes