Merged xyc's fixes to SP
Somehow exidl's pull request for unix stuff removed this fix from xyc in codemp.  We should watch out for more of these