more refactoring and beginnings of 'program' support