Control logic (still testing).