Fixed bug with output pkl file.