Copied from updated win version, still some tweaking needed