Fix bugs in action handling