Add comments and check for base directory

Signed-off-by: Gianpaolo Macario <gmacario@gmail.com>