Improved sed command and other improvements.