This needs tests.