Some minor bug fixing