General cleanups and fixes

Hello there,

I've started using this and fixed a rather annoying bug where it would mis-handle services with multiple ports/bindings. You might like to merge this.