Make custom serializers type-friendly