Fix type hints and re-order imports