Add some more code documentation. Fix resign behaviour.