Fixes e refactoring