Add hasConnections() functions and replace all getConnections.isEmpty()
getConnections() actually copies the list, which takes more time. So this simpler method is supplied to speed things up.
If connections are needed at some point in the method, they are retrieved as late as possible, so that if we leave the method before, we don't copy the list.