some clean up and json helpers