Added support for removing empty optional elements