Removed casting to shared where as possible. Made __gshared visibly static.