refactoring, removed a lot of warnings