Rewite signing a bit, less cluttered

Also fixed the gaping security hole