Minor bugs and fixes