fix various bugs found when doing from-scratch install using py27