Added comments and improved regex.