~ ported to mono
~ merging from windows development