introduced template declarations before definition to make it compile on Linux