Restructured code--but not done yet.