fixes from evanb's fork