Tidying up code in some places