bug fixes and imporvements