Fix for https://github.com/tuplejump/stargate-core/issues/41 and https://github.com/tuplejump/stargate-core/issues/42