Changed for infinite loops on both ends and changed program initialization.