Fixed ticket #392, #403, #409