better width and height calculations fixes #9