Some code erros, better types