removed shit borrowed from upstream