consistent use of locking in all templates