Added barrier implementation for Mac; switched to use longs when appropriate.