Removing dead code and adding more assertions.