Fix compile errors and cleanup