Fixed compiler errors and some warnings.