Fixes for mksh, changing sed expressions for OS X