Several fixes and a huge refactoring