This got copy-pasta-ed a bit as we added a lot of new types. I refactored this out so we have the logic only once. Signed-off-by: Dan Lorenc <lorenc.d@gmail.com>