Changed implementation of Bd-matrix