Various minor code improvements