Rework program object API for last spawned process and error

Also move schedulder related variables from program to scheduler struct.