Typesafe Connection & Output.

No more casting around, they are dependent on the target type.
Minor formatting.
Composition of Connection over inheritance.
isValid method renamed.
Update Motion description.
Cleaning up Connection and Output implementations.

Moved below the declaration of the templates.