screen: fix some annoying bugs by importing patches from ArchLinux