Polished and refactored code

- K&R style syntax
- public only when necessary
- PascalCase for fields
- some other minor refactorings