lots of tiny bug fixes