Refactor Casts and Relations

closes #2