Replaced pickle with fancy JSON.

Explanation encoder/decoder are probably not in the best place though.