Separating code for broker and client lib