Fixed miscellaneous bugs and typos