Fixes for MVEL-308: NPEs during ASM optimization

Also preemptively fixed same bug for List optimization.