Fixed bug in stack plot
Clean code