Refactored matrix state class, renamed object to entity.