Minor fixes, thanks to Stackoverflow