Some fixes, some logging, some hacks I forgot to commit