Added stop button and handling of different actions.