Added option to use pickle/json