more bug fixes along the way