Split tir functions into its own file. Clean up view/return