Fixed tooltips going off-window.

Closes #304.