Fix messages and refactoring