fixed branching
fixed programs crashing when finished