Fixing validations and refactoring