Add better inline documentation and simplify some of the code.