Respect maximum size

Oops sorry I didn't branch this properly and don't have time right now. But take a look and see if its of interest. I can create the branch properly later.