More cleanup, fix some crashes and errors