Fix typing and other errors