Split the code into several files
Changed to synchrounous message transfer