Gradle update and code refactoring