A lot of small fixes for host code