adding json functionality and more tweaks