Updated gradle plugin, various tweaks and refactoring