PR re-factoring
Semantic and code changes.