bugfix #81, #100, #152, #157, #159