remove trailing space
Implement prepareStack and take formatter from longjohn