Reduce compiler warnings, clean up code