Cleanup and added documentation.