re-organize the code somewhat git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7351 ec53bebd-3082-4978-b11e-865c3cabbd6b