Some minor bug fixes and changes