MITM improvements

- improved error handling
- small cosmetic changes