Some minor bug fixes