Final clean up and documentation for the code