Refactor to deftype approach, using atom protocols