Rearranging library and other fixes for proper Gradle use