Fix #377 Crash in VirtualProgram::apply