Fix merge issues

Updating custom code to work with latest upstream merge.