Bugs fixed

Signed-off-by: Piotr Carewicz <piotr.carewicz@googlemail.com>