Minor fixes: sed replacement improvements