NullpointerException protection on stack operations

Signed-off-by: Alexander Skjolden <alex@plastboks.net>