I think that`s wrong algorithm to make a default size: for example 
![image](https://f.cloud.github.com/assets/5739599/1748105/9592facc-649e-11e3-9e86-d4d62b8ee7db.png)

You should seperate calculations for vertical and horizontal - don`t use both sizeX and sizeY to calculate each other.