Some fixes and optimisations.

Loading was getting a bit laggy, now back down to ~0.25s.