Fixed up encoding stage of trials