some bugfixes for things i noticed and new functionality for gates