Move whole association logic to class-based solution

The amount of switches and cases were just getting too complex to a
sane person to understand. Inheritance solves this for us.