bug fixes, fixed for building on mac