Removed unused classes, code cleunup

- Code formatting.
- Optimized queries.
- Better authentication.