Clean up functions and template links