Updated semaphores to run on Mac OS X. This also fixes Bug #4.