Some fixes based on BKA's findings