Fix template loading event flow