Widget, minor code cleanup:
Declaration and assignment of local variables in one line.
Merged if condition checks.
Added and removed newlines.
Added default case to switch (just a style issue).
Removed redundant brackets.
Fixed indentation.
Approved by PS Jenkins bot, Sam Spilsbury.