Finished Java version, need more testing