Fixed some miscellaneous bugs