Rewritten linux implementation