Small fixes on logic