Checking for null and undefined input, and improved documentation