Fixed ticket #392, #403, #408, #409