fix all the problems! sadly, these changes were actually multiple commits, but have been compressed into one here.