Added support for triggering switching using switchImage:on and switchImage:off events. Improved clarity of code.