with some bug fixes