Added support for conditional switching between back and home behaviour.