bug fixes and stability fix