more comments and added junit tests.