Mainly fixes MacOs X compatibility issues.