some bug fixes and stability improvements