this commit fixes many bugs the multiple pops bugs still need to be fixed and tested.