bug fixes and functionality