Fix a memory corruption issue on some systems
Fix minor issues I saw in passing