OS X fixes and optimizations

Here are my patches to make My Little Investigations behave better on OS X.