Refactoring and cleaning

Make things work again