Refactored and commented client daemon