Refactorization to remove redundant code.
Added check to see if synchronization is already running.
Close the connection listener.