Optimization of Input Factory class.

- use templating of Factory
- use in fields module