Tidied up implementation of clear()