Removed unused code, fixed compile issues and warnings.