Improved API so that the main handling can be surrounded with other
actions