Some refactoring
many changes