Cleaned up the code and its documentation.