Made some changes to increase mono compatibility.