Use types instead of classes

Fixes #639