Arguments check and refactoring inspired by Philipp Schmitt, packaged.