Tidy up earplug code