Add optimization for frame size
Some small fixes