bug fixes and handling