Various fixes & better logging