copy useful stuff from 'precise' branch