Modified stack type so nonemptiness is enforced.
Minor comment mods.