Bug fix: safer pop