stack transformations using LambdaCase
use stack transformation functions
some cleanup