Rewrote position code for the ui bubble (fixes #40 and #28)