Migrated to Gradle build system and some minor changes

edit: Do not merge, my copy somehow became horrendously disorganized.