Fixed primitive procedure bugs