big refactoring cleaning/bug solving