Bugfixes.

- Fixed #3281.
- Fixed #3166.
- Fixed #3286.