Fix multiple bugs.