Refactored for readability

- Formatting
- Documentation
- Variable naming
- TODOs