Refactor, improve action parsing