Fix memory handling mistakes
Make clean_search more generic
Tempfix for segfaults on exit

Segfault on exit was due to mainsearch being static and thus non
freeable. Maybe mainsearch should be allocated like the rest of the
structs.
Remove some magics in subsearch
Fix color bug when a folder is in the first 2 lines
Divide subsearch function into distinct functions