Minor code changes for better reuse