* Implemented the TODO's.
* Basically tried to fix castings and types.