Add connection throttling

This is not ready for merge!

_We_ need to write tests @marcusramberg - but please comment and review the code.

Sorry for doing refactoring in the same branch, but I had a hard time wrapping my head around the code as it was structured.
Removed my previous comment, I understood how the code actually works now, didn't notice the last after connect.