Applied Max OS X patch from skomatsu.comutt.