Arun, helped to diagnose the problem. The issue is that the following sequence
B = stream A through CMD;
store B into 'B1';
kicks in the optimization and as the result store users BinaryStorage to write the results of the first job.
When the second job starts to run, it realizes that it can reuse the results and tries to load them also using BinaryStorage which is wrong and causes exceptions since the tuples don't have structure expected by the second script.
The solution is to attach the original store function to the materialized results; however, the code changes for it are quite ugly.