Fix #58 and some QA bugs