Fixes template loading logic