Bug and Security fixes. Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Denis Shulyaka <Shulyaka@gmail.com>