Fix potential issues, clean up

Throw a dedicated InvalidComponentTypeException if encountering an unknown
class during component index lookup.

Make sure all singleton connections are null-checked before usage,
retroactively test for NPE causing situation found.

Move component array sorting to own private method.

Use getComponentInternal from getAllComponentsOnEntity