Fixed few bugs

Fixed few miscellaneous bugs.