Fix various trivial bugs