Refactoring + small fixes + typo