Updated code to be more portable.