Various minor bug-fixes