Manually ported McAndre's changes