apply fixes from @weiken1