code updated to better support mono. NOTE: Bug with some code on ubuntu!