improve register handling in p and P