Smart recoloring

+ refactors