made json friendly, cleaned some code and prettified printing