Some code cleanup and refactoring for future maintainability