Fixed multiple issues in particle code.