Logic controllers refactored: now templated