Some more bug fixes