Refactored sync code and added notes sync