Add comments and logging