Performance improvements

Performance testing. Optimizing the worst functions. Refactored
filterAttributes and applyAttributeScore