Fixed most build issues on MacOS X (Lion)