Work around a julia-0.4 type inference bug
Fix more julia 0.4 issues