Logic cleanup