Cleaned up _remove_bom function.