Implementing a stack.

Based on http://stackoverflow.com/q/24899083/509706.