Rearrange some functions

- also fix a bug with selecting a species with the mouse
Add polyfill for Element.scrollIntoViewIfNeeded