Code Optimizations and additional OSX support