Added some crazy template hackery.