Fixed type-casting errors.
Removed end-of-line style comments.
Removed/added unused/missing function delclarations.