Additional cleanup; removing unused functions and reorganizing.