Better width/height calculation.
Better mouse event handling.