More logging
Add context for safety
Several bugfixes