Implemented stack functionality.
fixed merge conflicts