Fix for issue 334 and some other last-minute fixes