Remove compilation warnings
Add smart narrowing
Small organization changes
Add replace wrapper