Ported a bunch of stack API functions.