Gateway Bug (develop)

This is the develop version of #491