Merge pull request #265 from yilongli/master

my first pull request; addressed comments from code review
Java backend: cleaned up methods related to maintaining variables inside a term; added some javadoc