bug fixing, small improvements