fix #336 (related: #151, #214, #288)