Fixed bug with locale removing. Refactoring