Fixed multiple bugs.