Restructure and add a bunch of documentation.