(1) All costs, charges and expenses of and incidental to the presentation of a petition, or of any proceedings consequent thereon shall be in the discretion of the Court or judge and shall be defrayed by the parties to the petition in such manner and in such proportions as the Court or judge may determine, regard being had to the disallowance of any costs, charges or expenses which may, in the opinion of the Court or judge, have been caused by vexatious conduct, unfounded allegations, or unfounded objections on the part of either the petitioner or the respondent, and regard also being had to the discouragement of any needless expense by throwing the burden of defraying the same on the parties by whom it has been caused, whether such parties are or are not on the whole successful.