Add lots of documentation and update code.