slight improvements to terribad code.