Refactor search

- pep8 some files
- make some function calls clearer

integration tests pass