rewrite of linux version, rearrange git