fixed few problems
rewritten stack in c++