Warning fixes
Code refactoring