Refactoring the code to remove warnings.