More using decltype, typedef inside functions so that nasty decltype expression isn't repeated so many times