Various bug fixes that Kyle found