compile and bug fixes for OSX