Updated Java Implementation

Still not enough comments in here for what is going on, but it's been a
while since I didn't much (any) Java...