reduced duplicate code, improved option handling, and removed unnecessary openstruct attribute initialisations