now closing the eye_task properly when switching between tasks. Also did some refactoring.