refactoring, fixing warnings