Convert list accessors to templates and optimize

Reviewer: @wilmo119

Moves some of the table lookups and indirect function calls from runtime to codegen, which halves the cost of these functions. Also continues the process of moving legacy generated code to templates.
new empty line intended?