Fixed logical errors

Signed-off-by: Tanel Dettenborn <dettenbo@cs.helsinki.fi>