some bug fixes etc