Clarified general structure with barely adequate comments.