Refactored to improve maintainability

- Better management of different collection types.
- Cleaner Code at some places
- Minor fixes & improvements