fixed stuff after import from devonjones's fork