fixed a few bugs before building for osx/linux