Tweaked codes for consistency. Reworked stack implementations.