Add Mac OSX project
Fix some resource leaks by using RAII