Code optimization & cosmetics

- Removed dormant code
- Fixed typos and formatting
- completed documentation
- Optimized for codesize