Small fixes in logic. RC candidate