Code cleanup and better documentation.