Fixed some small mistakes and unnecessary casts