Abstract. In this paper, we introduce a new algebraic concept, which we call squarefree P -modules. This concept is inspired from Karu's proof of the nonnegativity of the cd-indices of Gorenstein* posets, and supplies a way to study cd-indices from the viewpoint of commutative algebra. Indeed, by using the theory of squarefree P -modules, we give several new algebraic and combinatorial results on CW-posets. First, we define an analogue of the cd-index for any CW-poset and prove its non-negativity when a CW-poset is Cohen-Macaulay. This result proves that the h-vector of the barycentric subdivision of a Cohen-Macaulay regular CW-complex is unimodal. Second, we prove that the Stanley-Reisner ring of the barycentric subdivision of an odd dimensional Cohen-Macaulay polyhedral complex has the weak Lefschetz property. Third, we obtain sharp upper bounds of the cd-indices of Gorenstein* posets for a fixed rank generating function.