WIP. Additional code cleanup.