some final bug fixes