More code cleanup and documentation

Did some more cleanup and documentation. Will add layer 1 framing and layer 0 error correction and noise simulation next.