Made code nicer by using existing macros
More failure handling in the right places, and make sure that newly generated poses are actually different from the old ones