More sharing in Logic, together with some code cleaning.