Various fixes to get it all working.