Ported BodyState.js, see #138