Update main.py

Added index system skeleton, fixed saving multiple roles, improved IO, improved search algorithm