Improved logging in brain.py