Removed globals and added comments to search.js