fix bug in multi-pk and move globals