Further optimized service.py and indentation issues