[WIP] Refactoring

Do not merge yet.