Fix multiple trivial bugs