Refactor: - code cleanup and some minor optimizations.