Fixed a few typos and casting issues