Fixing compile warnings and errors