Added simple CTC mode timer routine plus some minor code cleanup.