Refactored really hard. Thx Enrico.