Layout/dynamic page count

We have finally faced the layout problem so we could safely close #2.

Maybe we could refactor code a bit? @stegiorgi