move some template complexity to typedefs, fix gcc