Made pipe code OS X compatible; minor tweaks