Warning fixes
A bit of refactoring done