Made some minor changes to auxiliary functions