Bug Fixes

Fixed bugs in code