updated some code for json compatability.