Sorted, formatted, and added javadoc comments to the code.