bug fixes and api additions