fixes to previous commit as suggested by perexg