structural refactor and cleanup