Added XML documentation

- Added XML doc
- Minor refactoring