M: Renamed variable.
M: Removed trailing whitespaces.
M: Changed tabs to spaces.
M: Replaced two nested if blocks with one.
M: Simplified initialization of action callbacks.
M: Simplified sanity check.
M: Added more test-cases.