work in #1765 #1611 and fix for release build