WIP. Code cleanup