NOBUG: General coding fixes.

This includes:
- whitespace cleanup.
- variable names normalization.
- comments style.
- unused, undefined fixes.
- small API changes and visibility cleanup.