Updated stack implementation by using arrays. Much more readable and maintainable.