Minor fixes to prevent bugs