General project updates, Gradle build, Travis CI

This PR contains general project maintenance related commits:
- Add Gradle build and wrapper files
- Make this project buildable through Travis continuous integration
- Minor code changes (mostly cleanup and some consolidation of code duplication)