Some improvement.

Moved more logic to fsm.
Figured out footer height calculation issue.

Looks close.