added documentation and made a bunch of cosmetic renames