bug fixes after further testing