added comments to all functions in tools.php