Code refactoring (WIP)