Some bug fixing