Fixing compiler warnings, code tidying.