Fix simulator bugs.