Refactoring Action template into sub templates + code cleanup + bug fixes