miscellaneous bugs fixed. Working for now.