Fixed bugs in PDsim