Big refactoring, not sure if everything works
Merged with refactoring