search: Added weight_expression() function
search: Added constant PATTERNS list
search: Added comments and more explicit variables