Removed unused code and fixed some warnings.