Various fixes as per Emz' comments