Small code improvements/fixes