Several minnor fixes