removed the -contents field

also did some realy minor refactorings
extracted duplicated code