fix stem layout; some optimizations
optimize stem layout