better null check for stack (closes #354)