WIP. Code cleanup.