reorganization and outline of configure system (some code taken from Aquarius)