Mac build prep

Adjust code so it compiles and works under mac.