This needs a bit of cleanup