Fix compiler warnings, add err messages