Continued refactoring + code cleanup:

- Fixed compiler errors / warnings
- Fixed unit tests
- Expanded unit tests to cover more code
- Clearified documentation
- Fixed minor issues