Bugfixes e refactories