Small fixes to card database storing, made searching a bit more flexible, minor fixes, cleanup, refactoring