Stacksnippet optimize

Took care of a TODO in the code. Instead of building a long string and then cutting, it will only build as long of a string as it needs to.
Also reformatted file since it was messy with mixed tabs and spaces.