Added comments and function checks.