Code restructuring. Duplicates removed.