Bug Fixes

Fixed bugs introduced in the conversion from c#
All Test cases should pass now