Bug fixes for new typing code