some bug fixes