Small fix
Refactoring and fixes