Fixed some nullpointers

Fixed nullpointer when trying to count items in stacks that were being
null