Refactory some functions
Sync
Move linux code